package org.wlldTest.lesson10;


import org.dromara.easyai.entity.ThreeChannelMatrix;
import org.dromara.easyai.matrixTools.Matrix;
import org.dromara.easyai.tools.MeanClustering;
import org.dromara.easyai.tools.Picture;

import java.util.Arrays;

public class Test {
    public static void main(String[] args) throws Exception {
        test();
    }

    public static void test() throws Exception {
        ThreeChannelMatrix a = Picture.getThreeMatrix("/Users/lidapeng/job/faceData/youer/a1.jpg", false);
        ThreeChannelMatrix b = Picture.getThreeMatrix("/Users/lidapeng/job/faceData/youer/a2.jpg", false);
        float[] af = mean(a);
        float[] bf = mean(b);
        System.out.println("a:" + Arrays.toString(af));
        System.out.println("b:" + Arrays.toString(bf));

    }

    public static float[] mean(ThreeChannelMatrix t) throws Exception {
        MeanClustering meanClustering = new MeanClustering(3, 50);
        int x = t.getX();
        int y = t.getY();
        Matrix matrixR = t.getMatrixR();
        Matrix matrixG = t.getMatrixG();
        Matrix matrixB = t.getMatrixB();
        for (int i = 0; i < x; i++) {
            for (int j = 0; j < y; j++) {
                float[] color = new float[]{matrixR.getNumber(i, j), matrixG.getNumber(i, j), matrixB.getNumber(i, j)};
                meanClustering.setFeature(color);
            }
        }
        meanClustering.start();
        return meanClustering.getResultByNorm();
    }


}
